/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wrap.core;

import java.applet.*;
import java.io.InputStream;
import java.net.URL;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;

/**
 *
 * @author Lazlo
 */
public class CSound extends Applet{
    private AudioClip currentSound;

   public void playSound(String page){
        stopSound();


        System.out.println("CSound is going to play: " + page);
        URL url = wrap.sounds.Sounds.class.getResource(page + ".wav");
        System.out.println("trying to play " + url);
        AudioClip clip = Applet.newAudioClip(url);
        
        playSound(clip);
    }

   public boolean isPlaying(){
       boolean result = false;
       return result;
   }

   private void playSound(AudioClip clip){
       try{
            currentSound = clip;
            currentSound.play();
        } catch(Exception e){
            System.out.println(e);
        }
   }

   public void stopSound(){
       if(currentSound != null)
           currentSound.stop();
   }
}
